package com.boesch.electroOffice.dataaccess.mapper.messerli;

import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import com.boesch.electroOffice.model.messerli.Customer;

/**
 * This class mappes the rows from messerli database to a Customer object.
 * 
 * @author Ralph Koster
 *
 */
public class CustomerMesserliMapper implements RowMapper<Customer>, Serializable {

	private static final long serialVersionUID = -5261216200859169416L;

	/**
	 * Mapps all rows from database to a Customer object.
	 * 
	 * @see org.springframework.jdbc.core.RowMapper
	 */
	public Customer mapRow(ResultSet rs, int rowNum) throws SQLException {
		Customer customer = new Customer();
		customer.setCustomerId(rs.getInt("NUMMER"));
		customer.setSalutation(rs.getString("ANREDE"));
		customer.setFirstname(rs.getString("VORNAME"));
		customer.setLastname(rs.getString("NAME"));
		customer.setPoBox(rs.getString("POSTFACH"));
		customer.setStreet(rs.getString("STRASSE"));
		customer.setPlz(rs.getString("PLZ"));
		customer.setCity(rs.getString("ORT"));
		customer.setCountry(rs.getString("LAND"));
		customer.setTelPrivate(rs.getString("TELP"));
		customer.setTelBusiness(rs.getString("TELG"));
		customer.setFax(rs.getString("FAX"));
		customer.setMobile(rs.getString("NATEL"));
		customer.setEmail(rs.getString("EMAIL"));
		customer.setHomepage(rs.getString("HOMEPAGE"));

		return customer;
	}
}
